package com.im.foodorderingsystem;

import android.content.Context;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.im.foodorderingsystem.db.FOSDB;
import com.im.foodorderingsystem.task.SyncTask;

public class Home extends ActionBarActivity {

	SharedPreferences fosSettings;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_home);

		fosSettings=getSharedPreferences("fosSettings", Context.MODE_PRIVATE);
		
		String user_id=fosSettings.getString("user_id", "");
		String email=fosSettings.getString("email", "");
		
		SyncTask sync = new SyncTask(this);
		sync.execute();
		
		System.out.println("Home>> user_id="+user_id+" email="+email);
		
	
		//String sql="insert into category (name) values('asd')";
		//db.execSQL(sql);
		FOSDB fosdb=new FOSDB(getApplicationContext());
		SQLiteDatabase db=fosdb.getReadableDatabase();
		//String sql="insert into category (name) values('asd')";
		//db.execSQL(sql);
		
		System.out.println("call db");
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.home, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
	
	public void openMunu(View v){
		
	}
	
	public void openContactUs(View v){
		
	}
	
	public void openHistory(View v){
		
	}



}
